package com.cote.douhahou.pretloan.msg.widget;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.cote.douhahou.pretloan.beans.ProcesAkomapalendsInfoData;
import com.cote.douhahou.pretloan.network.HttpHelper;
import com.cote.douhahou.pretloan.R;
import com.cote.douhahou.pretloan.msg.DatePAkomapalendickerDialog;


public class DateSAkomapalendelectViewManager extends BaseProcAkomapalendessWidgetManager {

    private TextView titl_akomapalendeTv;
    private TextView inpu_akomapalendtTv;

    public DateSAkomapalendelectViewManager(View view, ProcesAkomapalendsInfoData data, String page){
        super(view,data,page);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void in_akomapalendit(){

        titl_akomapalendeTv = mVi_akomapalendew.findViewById(R.id.vpds_tv_title);
        inpu_akomapalendtTv = mVi_akomapalendew.findViewById(R.id.vpds_tv_input);

        setTi_akomapalendtle(mDa_akomapalendta.getTitle_akomapalend());
        inpu_akomapalendtTv.setHint(mDa_akomapalendta.getHint_akomapalend());

        mVi_akomapalendew.findViewById(R.id.vpds_view_click).setOnClickListener(v -> {

            HttpHelper.inst().submitEvent(pa_akomapalendge, mDa_akomapalendta.getParamName_akomapalend().toUpperCase()+"_CLICK","");

            new DatePAkomapalendickerDialog(
                    mVi_akomapalendew.getContext(),
                    mDa_akomapalendta.getTitle_akomapalend(),
                    date -> {
                        inpu_akomapalendtTv.setText(date);
                        HttpHelper.inst().submitEvent(pa_akomapalendge, mDa_akomapalendta.getParamName_akomapalend().toUpperCase()+"_CLICK", getInp_akomapalendut());
                    }
            ).show();
        });

    }

    @Override
    public boolean checkI_akomapalendnput() {
        if (!mDa_akomapalendta.isMustInput_akomapalend()) return true;
        return !TextUtils.isEmpty(inpu_akomapalendtTv.getText());
    }

    @Override
    public String getInp_akomapalendut() {
        return inpu_akomapalendtTv.getText().toString();
    }

    public void setTi_akomapalendtle(String title){
        if (TextUtils.isEmpty(title)) titl_akomapalendeTv.setVisibility(View.GONE);
        else {
            titl_akomapalendeTv.setVisibility(View.VISIBLE);
            titl_akomapalendeTv.setText(title);
        }
    }


}
